package com.inspur.gs.sbssdl.sbwhgl.sbrh.sbrh.back.luCreatFactory;

import com.inspur.edp.wf.runtime.api.payload.StartProcessPayload;
import com.inspur.edp.wf.runtime.entity.ExecutionResponse;
import io.iec.edp.caf.rpc.api.service.RpcClient;
import io.iec.edp.caf.commons.utils.SpringBeanUtils;
import java.util.LinkedHashMap;

public class TaskFlowCreater {

    public static void getTaskFlow(String dataId,String bizDefKey) {
        if (dataId == null || bizDefKey == null)  return;
        if (dataId.isEmpty() || bizDefKey.isEmpty())  return;

        RpcClient rpcClient = SpringBeanUtils.getBean(RpcClient.class);
        String serviceId = "com.inspur.edp.wf.runtime.api.RuntimeExecutionService.startProcess";
        String suName ="sbwhgl";
        StartProcessPayload startProcessPayload = new StartProcessPayload();
        startProcessPayload.setBizDefKey(bizDefKey);//流程分类Id
        startProcessPayload.setDataId(dataId);//单据内码
        startProcessPayload.setName(null);//流程实例名称，可空
        startProcessPayload.setVariables(null);//流程入参，可空
        LinkedHashMap<String, Object> params = new LinkedHashMap<>();
        params.put("startProcessPayload",startProcessPayload);
        try {
            ExecutionResponse response = rpcClient.invoke(ExecutionResponse.class, serviceId, suName, params,null);
        } catch (Exception e) {
            throw e;
        }
    }

}
